using System;
using UnityEngine;
using WorldMapBase.Tile;
using Yoozoo.Gta.Common;

namespace UnityGameFramework.Runtime
{
    public sealed partial class DebuggerComponent : GameFrameworkComponent<DebuggerComponent>
    {
        private sealed class SLGDebugParamsWindow : ScrollableDebuggerWindowBase
        {
            protected override void OnDrawScrollableWindow()
            {
                GUILayout.Label("<b>Debug Settings</b>");
                GUILayout.BeginVertical("box");
                {
                    OnDrawHorizontalToggle("打印沙盘物体数量Log", DebugSetting.ShowObjectNumLog,"", (b) =>
                    {
                        DebugSetting.ShowObjectNumLog = b;

#if UNITY_EDITOR
                        if (b)
                        {
                            TileDisplayManager.Instance.ShowDebugInfo();                                
                        }                 
#endif

                    });
                    
                    OnDrawHorizontalToggle("内城网格常驻显示", DebugSetting.PermanentCityGrid,"", (b) =>
                        {
                            DebugSetting.PermanentCityGrid = b;
                        });
                    
                    OnDrawHorizontalToggle("点击建筑显示坐标", DebugSetting.ClickShowPos,"", (b) =>
                    {
                        DebugSetting.ClickShowPos = b;
                    });

                }
                
                GUILayout.EndVertical();

            }
            
            private void OnDrawHorizontalToggle(string label, bool value, string toogleStr, Action<bool>
                modifyCallback = null)
            {
                GUILayout.BeginHorizontal();
                {
                    bool temp = value;
                    label = string.Format("{0}:{1}", label, value);
                    GUILayout.Label(label, GUILayout.Width(200f));
                    temp = GUILayout.Toggle(value, toogleStr, GUILayout.Width(200f));
                    if (temp != value)
                    {
                        if (modifyCallback != null)
                        {
                            modifyCallback(temp);
                        }

                        value = temp;
                    }
                }
                GUILayout.EndHorizontal();
            }
        }
    }
}